Skip to content

fix(feature_flags): warn on comparator evaluation errors - #8470

Merged
leandrodamascena merged 3 commits into
aws-powertools:developfrom
Shubham-Padkonde:fix/feature-flag-comparator-warnings
Sep 28, 2026
Merged

leandrodamascena merged 3 commits into
aws-powertools:developfrom
Shubham-Padkonde:fix/feature-flag-comparator-warnings

Conversation

@Shubham-Padkonde

@Shubham-Padkonde Shubham-Padkonde commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Issue number: closes #8425

This covers step 1 of #8425 (warning-only). Step 2, a dedicated exception in the next major version, is still open, so please reopen the issue or split it out if you want to track that separately.

Summary

Changes

Emit a warning when a feature-flag comparator raises while evaluating a present context key. Include the feature, rule, key, action, and exception type, without exposing operand values or exception messages. Pass that diagnostic context through the private comparator helper and document the warning.

User experience

Incompatible operands, such as STARTSWITH on an integer, currently look like ordinary non-matches unless debug logging is enabled. They now produce an actionable warning. Existing non-match results and registered exception handlers are preserved; missing keys and valid non-matches stay quiet.

This implements the first step proposed in the issue. Introducing a new exception remains a separate major-version decision. The tested approach was described in the issue before submission.

Validation:

  • Initial functional regression: 7 failed, 2 passed before the change; 9 passed after. An additional exception-message privacy regression brings the final focused suite to 10 passing cases.
  • Full non-performance suite on Python 3.12/Linux: 2,579 passed, 4 skipped, 10 deselected; coverage 96.69%.
  • All 10 performance checks passed.
  • Repository Ruff checks, mypy (897 source files), security and complexity baselines, and modified-Python pre-commit checks passed.
  • make pr stops at its Docker-based documentation command because Docker/WSL integration is unavailable here. Running markdownlint directly passes the edited page; the full docs check reports the pre-existing MD053 error in unchanged docs/changelog.md:1. The remaining check categories were run separately as listed above. AWS end-to-end and Redis integration tests were not run.

Prepared with OpenAI Codex assistance.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Shubham-Padkonde
Shubham-Padkonde requested a review from a team as a code owner September 16, 2026 22:12
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 16, 2026
@boring-cyborg boring-cyborg Bot added documentation Improvements or additions to documentation tests labels Sep 16, 2026
@boring-cyborg

boring-cyborg Bot commented Sep 16, 2026

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor Author

This implements only the warning-only first step of #8425; the proposed major-version exception behavior remains open. The related-issue check currently requires a development link or a closing keyword. Could a maintainer link #8425 manually (or advise the preferred tracking issue for this first step)? I have avoided a closing keyword so merging this PR does not inadvertently close the remaining major-version work.

@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.80%. Comparing base (084a541) to head (5df770c).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8470   +/-   ##
========================================
  Coverage    96.80%   96.80%           
========================================
  Files          310      310           
  Lines        15534    15541    +7     
  Branches      1353     1354    +1     
========================================
+ Hits         15037    15044    +7     
  Misses         361      361           
  Partials       136      136           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@leandrodamascena leandrodamascena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, @Shubham-Padkonde, and thanks for working on this! I pushed a follow-up to your branch after finding that the default package logger was still swallowing the warning. It now uses warnings.warn(), with protection for -W error so evaluation and registered handlers keep working.

@mergify

mergify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@leandrodamascena
leandrodamascena merged commit 1a6c4c6 into aws-powertools:develop Sep 28, 2026
14 checks passed
@boring-cyborg

boring-cyborg Bot commented Sep 28, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@powertools-for-aws-oss-automation

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: surface comparator exceptions as misconfiguration instead of silent non-match

2 participants